#include <stdio.h>
#include <math.h>

int main() {
    double pi = 0.0, term = 1.0;
    int sign = 1, n;
    for (n = 1; n <= 100000; n += 2) {
        pi = pi + term;
        sign = -sign;
        term = sign * (1.0 / n);
        if (fabs(term) <= 1e-8)
            break;
    }
    pi = pi * 4;
    printf("π的近似值为:%lf", pi);
    return 0;
}